<?php
namespace Admin\Form;
use Common\Form\BaseForm;
use Common\Model\UserMessageModel;
class ServiceForm extends BaseForm {
    public static function newSelf()
    {
        return new self();
    }
    protected $data;
    protected $action;
    protected $return_type;
    public function __construct()
    {
        set_time_limit(0);
        parent::__construct();
        $this->return_type='ajax';
        $this->data['backMessage']=[
            'fid'=>'id',
            'title'=>'title',
            'username'=>'username',
            'content'=>'content'
        ];
    }
    public function backMessage($input)
    {
        $this->return_type='error';
        $this->action='backMessage';
        $this->__toInitialize($input);
        $this->emptyVerification('username', '请填写留言用户');
        $info=$this->findUserByUserName('username', '用户不存在');

        $this->emptyVerification('title', '请填写标题');
        $this->emptyVerification('content', '请填写内容');
        
        $this->addDataVal('sendee_id', $info['id']);
        $this->addDataVal('type',13);;
        $this->addDataVal('add_time',time());
        $this->delDataVal('username');
        $res=UserMessageModel::newSelf()->add($this->getAllData());
        $this->resReturn($res, '留言成功', '留言失败');
    }
    
   
    
}